package com.cn.longdistancebusstation.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.TextView;
import android.widget.Toast;

import com.cn.longdistancebusstation.R;
import com.cn.longdistancebusstation.base.BaseFragment;
import com.cn.longdistancebusstation.httpHelper.HttpHelper;
import com.cn.longdistancebusstation.httpapi.HttpService;
import com.cn.longdistancebusstation.model.ListResult;
import com.cn.longdistancebusstation.model.ListResultIII;
import com.cn.longdistancebusstation.model.ScenicDetails;
import com.cn.longdistancebusstation.model.Ticket;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;

/**
 * Created by mucheng on 2018/3/29.
 */

public class OrderNoteFragment extends BaseFragment{
    private WebView scenicIntroduce;
    private String orderNote;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.order_note_fragment,null);
        scenicIntroduce=(WebView) view.findViewById(R.id.scenic_details);
        Intent in=getActivity().getIntent();
        orderNote=in.getStringExtra("orderNote");
        StringBuilder sb = new StringBuilder();
        //拼接一段HTML代码
        sb.append("<html>");
        sb.append("<head>");
        sb.append("<title></title>");
        sb.append("</head>");
        sb.append("<body>");
        sb.append("<h2>"+orderNote+"</h2>");
        sb.append("</body>");
        sb.append("</html>");
        //使用简单的loadData方法会导致乱码，可能是Android API的Bug
        //show.loadData(sb.toString(), "text/html", "utf-8");
        //加载、并显示HTML代码
        String content = Html.fromHtml(orderNote).toString();
        scenicIntroduce.loadDataWithBaseURL(null,content, "text/html", "utf-8", null);
        scenicIntroduce.getSettings().setJavaScriptEnabled(true);
        scenicIntroduce.getSettings().setDefaultTextEncodingName("UTF_8");
        scenicIntroduce.setBackgroundColor(0);
        return view;

    }
}
